<?php

namespace app\api\controller\v1;

use app\api\model\CatchError as CatchErrorModal;
use think\Controller;
use think\Exception;

class CatchError extends Controller
{
  public function saveErrorInfo() {
    // 无需校验参数
    $type = request()->param('type');
    $name = request()->param('name');
    $info = request()->param('content');
    $error = new CatchErrorModal([
      'name' => $name,
      'type' => $type,
      'content' => $info
    ]);
    $result = $error->save();
    return json($result);
  }

  public function getErrorInfo ($name, $pageIndex) {
    $res = CatchErrorModal::where('name', $name)->order('id desc')->paginate(20, true, ['page' => $pageIndex]);
    return json($res);
  }
}